package solution;

/**
 * @author : wenchao.long
 * @date : Created in 2024-07-03 下午 11:31 周三
 * @description :
 * 		<a href="https://leetcode.cn/problems/minimum-moves-to-reach-target-score/description/">得到目标值的最少行动次数</a>
 * 	<p>
 * 	    采用倒推，既然是从1 -> 目标target值
 * 	    反过来 用 target得到 1
 * 	</p>
 */
public class No2139 {

	public static int minMoves(int target, int maxDoubles) {
		if (target == 1) {
			return 0;
		}
		if (maxDoubles == 0) {
			return target - 1;
		}
		return 1 + (target % 2 == 0 ? minMoves(target / 2, maxDoubles - 1) : minMoves(target - 1, maxDoubles));
	}

	public static void main(String[] args) {
		System.out.println(minMoves(121201221, 100));
	}
}
